{% extends 'base.html' %}

{% block breadcrumb_current %}
    物料参数 > 仓库管理 > 新增仓库
{% endblock %}

{% block content %}

    {% if messages %}
        {% for message in messages %}
            <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
                {{ message }}
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
        {% endfor %}
    {% endif %}
    
    <div class="bg-light p-3 shadow-sm">
        <h5 style="color: #417690;">
            新增仓库
            <a href="{% url 'warehouse_list' %}" class="btn btn-secondary btn-sm float-end" style="margin-left: 15px;">返回仓库列表</a></h5>
    </div>


<div class="container mt-4">
    <div class="card" style="margin-top: 50px;">
        <div class="card-body">
            <form method="post">
                {% csrf_token %}
                <div class="row"></div>
                <div class="col-md-2 mb-3 mx-auto" style="margin-top: 30px;">
                    <label for="{{ form.warehouse.id_for_label }}" class="form-label">仓库名称</label>
                    <input type="text" name="{{ form.warehouse.name }}" id="{{ form.warehouse.id_for_label }}" 
                           class="form-control {% if form.warehouse.errors %}is-invalid{% endif %}" 
                           value="{{ form.warehouse.value|default:'' }}">
                    <!-- {{ form.warehouse }} -->
                    {% if form.warehouse.errors %}
                        <div class="invalid-feedback">{{ form.warehouse.errors|join:", " }}</div>
                    {% endif %}
                </div>
                <div class="col-md-2 mb-3 mx-auto" style="margin-top: 30px;">
                    <label for="{{ form.department.id_for_label }}" class="form-label">所属县区</label>
                    <select name="{{ form.department.name }}" id="{{ form.department.id_for_label }}" 
                           class="form-control {% if form.department.errors %}is-invalid{% endif %}">
                        {% for value, text in form.department.field.choices %}
                            <option value="{{ value }}" {% if form.department.value == value %}selected{% endif %}>{{ text }}</option>
                        {% endfor %}
                    </select>
                    <!-- {{ form.department }} -->
                    {% if form.department.errors %}
                        <div class="invalid-feedback">{{ form.department.errors|join:", " }}</div>
                    {% endif %}
                </div>
                <div class="text-center"  style="margin-top: 30px;">
                    <button type="submit" class="btn ms-2" style="background-color: #417690; color: white;">保 存</button>
                    <!-- <a href="{% url 'warehouse_list' %}" class="btn btn-secondary">取消</a> -->
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}